package com.czkj.hwz.decorate.utils;

import android.graphics.Color;
import android.text.Spannable;
import android.text.SpannableStringBuilder;
import android.text.style.ForegroundColorSpan;

import com.czkj.hwz.decorate.R;

/**
 * Created by Administrator on 2017/10/6.
 */

public class MUtils {
    public static final String setForegroundColor(int colorId,String flag,String textInfo) {
        SpannableStringBuilder builder = new SpannableStringBuilder(textInfo);
        int startIndex = textInfo.indexOf(flag);
        if (startIndex <= -1) return textInfo;
        int endIndex = startIndex+ flag.length()-1 ;
        ForegroundColorSpan yellowSpan = new ForegroundColorSpan(Color.YELLOW);
        builder.setSpan(yellowSpan, startIndex,endIndex, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
        return builder.toString();
    }
}
